<?php $post = $this->get("post");?>
<div class="x-list-title">
<table height="100%" width="100%" border="0" cellpadding="0">
<tr><td>
<h2><?php _e($post['title'])?></h2>
</td><td align="right">
<div class="x-list-options">
	<a onclick="load_inframe('<?php _baseUrl();?>/Task/Comment/Add?task_id=<?php _e($post['ID'])?>',{auto_hidden:true,title: 'Thảo luận công việc'})" class="x-button x-button-add">Thảo luận</a>
	<a onclick="load_inframe('<?php _baseUrl();?>/Task/Index/Update?ID=<?php _e($post['ID'])?>',{auto_hidden:true,title: 'Cập nhật tiến độ công việc'})" class="x-button x-button-add">Tiến độ</a>
	<div class="x-options-container">
		<a class="x-button">Trạng thái <span>&#9660;</span></a>
		<div class="x-options">
			<a onclick="ajax_load('<?php _baseUrl()?>/Task/Index/Status?ID=<?php _e($post['ID'])?>&status=complete')" class="x-options-item">Hoàn thành</a>
			<a onclick="ajax_load('<?php _baseUrl()?>/Task/Index/Status?ID=<?php _e($post['ID'])?>&status=inactive')" class="x-options-item">Tạm dừng</a>
			<a onclick="ajax_load('<?php _baseUrl()?>/Task/Index/Status?ID=<?php _e($post['ID'])?>&status=active')" class="x-options-item">Thực hiện</a>
			<a onclick="ajax_load('<?php _baseUrl()?>/Task/Index/Status?ID=<?php _e($post['ID'])?>&status=cancel')" class="x-options-item">Hủy bỏ</a>
		</div>
	</div>
	<div class="x-options-container">
		<a class="x-button">Tác vụ khác <span>&#9660;</span></a>
		<div class="x-options">
			<a class="x-options-item" href="#Task/Search/Form">Tìm kiếm nâng cao</a>		
			<a class="x-options-item" onclick="ajax_load('<?php _baseUrl();?>/Task/Act?act=unread&ID[]=<?php _e($post['ID'])?>&back=yes')">Đánh dấu chưa đọc</a>
			<a href="#Task/Index/Edit?ID=<?php _e($post['ID'])?>" class="x-options-item">Sửa công việc</a>
			<a onclick="module_delete('<?php _baseUrl()?>/Task/Index/Delete?ID=<?php _e($post['ID'])?>')" class="x-options-item">Xóa công việc</a>
			<a href="#Task/Index/Add?ID=<?php _e($post['ID'])?>" class="x-options-item">Tạo công việc mới</a>
		</div>
	</div>
</div>
</td></tr></table>
</div>
<table width="100%" border="0" class="x-info" cellspacing="0">
<tr>
	<td colspan="4" align="right" class="x-info-top">
		<span class="tl">Thông tin chi tiết</span>
		<span class="tr">Cập nhật lần cuối lúc <?php _e( show_date(DATETIME_FORMAT,$post['date_updated']) );?> bởi <?php _e(get_user_link( $post['updated_by_id'],$post['updated_by_name'],$post['updated_is_deleted']) );?></a></span>
	</td>
</tr>
<tr>
	<td class="x-info-label" nowrap="nowrap">
		Tên công việc
	</td>
	<td class="x-info-content">
		<span class="code"><?php _e( $post['title'] );?></span>
	</td>
	
	<td class="x-info-label" nowrap="nowrap">
		Người giao
	</td>
	<td class="x-info-content">
	<?php _e( get_user_link($post['created_by_id'],$post['created_by_name'],$post['created_is_deleted']) );?>
	</td>
</tr><tr>	
	<td class="x-info-label">
		Bắt đầu
	</td>
	<td class="x-info-content">
	<span class="time"><?php _e( show_date(TIME_FORMAT,$post['date_start']) );?></span> <?php _e( show_date(DATE_FORMAT, $post['date_start']) );?>
	</td>
	<td class="x-info-label" nowrap="nowrap">
		Kết thúc
	</td>
	<td class="x-info-content">
	<?php if( $post['date_end'] ):?>
		<span class="time"><?php _e( show_date(TIME_FORMAT,$post['date_end']) );?></span>  <?php _e( show_date(DATE_FORMAT,$post['date_end']) );?>
	<?php else:?>
	<i>Không xác định</i>	
	<?php endif;?>
	</td>
</tr>
<tr>	
	<td class="x-info-label" nowrap="nowrap">
		Tình trạng
	</td>
	<td class="x-info-content">
	<?php _e( get_status($post['status']) );?>
	</td>
	<td class="x-info-label">
		Dự án
	</td>
	<td class="x-info-content">
	<a href="#Project/Index/View?ID=<?php _e($post['project_id']);?>">
		<?php _e($post['project_title']);?></a>		
	</td>
</tr>
<tr>
	<td class="x-info-label">
		Tiến độ
	</td>
	<td class="x-info-content">
		<div class="x-progress"><div title="<?php _e( (int)$post['rate'] );?>%" style="width:<?php _e( (int)$post['rate'] );?>%"></div></div>
		<?php _e( (int)$post['rate'] );?>% <br/>		
	</td>
	<td class="x-info-label">
		Mức ưu tiên
	</td>
	<td class="x-info-content">
	<?php _e( get_priority($post['priority']) );?>
	</td>

</tr>
<tr>
	<td class="x-info-label">
		Người thực hiện
	</td>
	<td class="x-info-content">
	<?php $a=array();?>
	<?php foreach( $this->get('users') as $u ):?>
	<?php if( $u['is_implement'] == 'yes'):?>
	<?php $a[]= get_user_link($u);?>
	<?php endif;?>
	<?php endforeach;?>	
	<?php _e(implode(", ",$a));?>
	<?php if( count($a) == 0 ) _e('<i>Không có</i>');?>
	</td>
	<td class="x-info-label">
		Người được xem
	</td>
	<td class="x-info-content">
	<?php $a=array();?>
	<?php foreach( $this->get('users') as $u ):?>
	<?php if( $u['is_guest'] == 'yes'):?>
	<?php $a[]= get_user_link($u);?>
	<?php endif;?>
	<?php endforeach;?>	
	<?php _e(implode(", ",$a));?>
	<?php if(count($a)==0) _e('<i>Không có</i>');?>
	</td>
</tr><tr>	
	<td class="x-info-label">
		Loại công việc
	</td>
	<td class="x-info-content">
		<a href="#Task/Index/Group?parent_id=<?php _e($post['parent_id']);?>"><?php _e($post['parent_title']);?></a>
	</td>
	<td class="x-info-label" nowrap="nowrap">
	</td>
	<td class="x-info-content">
	</td>
</tr>
<tr>
	<td class="x-info-label x-info-label-last">
		Mô tả
	</td>
	<td colspan="3" class="x-info-content">
		<?php _e( $post['desc'] );?>
	</td>
</tr>
<tr>
	<td class="x-info-label x-info-label-last">
		Đính kèm
	</td>
	<td colspan="3" class="x-info-content">
	<?php $a=array();?>
	<?php foreach( $this->get('files') as $f ):?>
	<?php show_thumb( $f, baseUrl()."/Task/Index/File?ID={$f['ID']}");?>
	<?php endforeach;?>	
	</td>
</tr>
<tr>
	<td colspan="4" align="left" class="x-info-top">
		<span class="tl">Thảo luận</span>
		<a class="tr" href="#Task/Index/View?ID=<?php _e($post['ID'])?>&ord=<?php _e(get('ord') == 'desc' ? 'asc' :'desc' );?>">Sắp xếp</a>
	</td>
</tr>	
<!--COMMENT LIST-->
<?php if( count( $this->get("comments") ) > 0 ):?>
	<?php foreach( $this->get("comments") as $k => $a ): ?>
	<tr>
		<td class="x-info-comment" align="center">
			<?php if($a['created_by_photo']):?>
			<img class="comment-avatar" src="<?php _baseUrl()?>/files/photo/<?php _e($a['created_by_photo'])?>"/>
			<?php else:?>
			<img class="comment-avatar" src="<?php _baseUrl()?>/files/photo/noavatar.gif"/>
			<?php endif;?>
		</td>
		<td valign="top" align="left" colspan="3">
			<div class="comment-bar">
				<span class="comment-copy">Đăng bởi <?php _e(get_user_link($a['created_by_id'],$a['created_by_name'],$a['created_is_deleted']) )?> 
					lúc <?php _e(show_date(TIME_FORMAT,$a['date_created']))?> <?php _e(show_date(DATE_FORMAT,$a['date_created']))?>
					<?php if( $a['date_updated'] != $a['date_created'] ):?>
					<span class="date-edit">( sửa lúc: <?php _e(show_date(TIME_FORMAT,$a['date_created']))?>  <?php _e(show_date(DATE_FORMAT,$a['date_created']))?> )</span>
					<?php endif;?></span>
				<span class="comment-button">
					<a onclick="load_inframe('<?php _baseUrl($this)?>/Task/Comment/Add?task_id=<?php _e($post['ID']);?>&comment_id=<?php _e($a['ID']);?>',{title:'Thảo luận mới', id:'CommentEdit<?php _e($a['ID'])?>', auto_hidden: true})">Trích dẫn</a> 
					<?php if( $a['created_by_id'] == get_user_id() ):?>
					 | <a onclick="module_delete('<?php _baseUrl($this)?>/Task/Comment/Delete?ID=<?php _e($a['ID']);?>')">Xóa</a> | 
					<a onclick="load_inframe('<?php _baseUrl($this)?>/Task/Comment/Edit?ID=<?php _e($a['ID']);?>',{title:'Sửa thảo luận', id:'CommentEdit<?php _e($a['ID'])?>', auto_hidden: true});">Sửa</a>
					<?php endif;?>
				</span>				
			</div>	
			<div class="comment-content">
				<?php _e($a['content']);?>
				<br/>
				<?php if( count($a['files']) > 0 ): ?>
				<u>Đính kèm:</u><br/>
				<?php foreach( $a['files'] as $f ): ?>		
				<?php show_thumb( $f, baseUrl()."/Task/Comment/File?ID={$f['ID']}");?>
				<?php endforeach;?>
				<?php endif;?>
			</div>
		</td>
	</tr>
	<?php endforeach;?>
<?php else:?>
<tr>
	<td colspan="4" class="x-info-content">		
		<i>Chưa có thảo luận nào</i>	
	</td>
</tr>
<?php endif;?>
</table>
<div align="right" style="padding:5px 0px">
<a onclick="load_inframe('<?php _baseUrl();?>/Task/Comment/Add?task_id=<?php _e($post['ID'])?>',{auto_hidden:true,title: 'Thảo luận công việc'})" class="x-button x-button-add">Thảo luận</a>
</div>
